'use strict';
import echarts from 'echarts';
import apiImplJsonConfig from '../service/common/Apis';
import {dimensionConfig} from '../data/dimensionConfig';
import DateUtils from '../util/DateUtils';
import StringUtils from '../util/StringUtils';
import ExcelExport from '../util/ExportExcelUtil';

/**
 * @ngdoc function
 * @name gempileInWebApp.controller:ResourceDispatchController
 * @description
 * Controller of the gempileInWebApp
 */
export default function ResourceDispatchController($scope, $filter, Excel, $timeout, $stateParams, HttpRequestService, CheckDateUtils) {
    $(".dispatch-tabs div").click(function(e){
        $(this).addClass("current");
        $(this).siblings().removeClass().addClass("dispatch-tab");

        var pageIndex = $("#tabs div").index($(this));
        var currentPageId = "#firstpage";
        switch(pageIndex){
            case 0:
                currentPageId = "#firstpage";
                break;
            case 1:
                currentPageId = "#secondpage";
                break;
            case 2:
                currentPageId = "#thirdpage";
                break;
        }
        $(currentPageId).show();
        $(currentPageId).siblings().hide();
    });
    $scope.servicetree = {
        obj: "",
        filter: "",
        data: [
            {
                id:1,
                name:"全选",
                children:[
                    {id: 1,name: '即时通信'},
                    {id: 2,name: '阅读'},
                    {id: 3,name: '微博'},
                    {id: 4,name: '导航'},
                    {id: 5,name: '视频'},
                    {id: 6,name: '音乐'},
                    {id: 7,name: '应用商店'},
                    {id: 8,name: '游戏'},
                    {id: 9,name: '支付'},
                    {id: 10,name: '动漫'},
                    {id: 11,name: '邮箱'},
                    {id: 12,name: 'P2P业务'},
                    {id: 13,name: 'VoIP业务'},
                    {id: 14,name: '彩信'},
                    {id: 15,name: '浏览下载'},
                    {id: 16,name: '财经'},
                    {id: 17,name: '安全杀毒'},
                    {id: 18,name: '其他业务'}
                ]
            }

        ]
    };
    $scope.netunittree = {
        obj: "",
        filter: "",
        data: [
            {
                id:1,
                name:"全选",
                children:[
                    {id: 1,name: 'DGSGW1001'},
                    {id: 2,name: 'DGSGW1002'},
                    {id: 3,name: 'DGSGW1003'},
                    {id: 4,name: 'DGSGW1004'},
                    {id: 5,name: 'DGSGW1005'},
                    {id: 6,name: 'DGSGW1006'},
                    {id: 7,name: 'DGSGW1007'},
                    {id: 8,name: 'DGSGW1008'},
                    {id: 9,name: 'DGSGW1009'},
                    {id: 10,name: 'DGSGW1010'},
                    {id: 11,name: 'DGSGW1011'},
                    {id: 12,name: 'DGSGW1012'},
                    {id: 13,name: 'DGSGW1013'},
                    {id: 14,name: 'DGSGW1014'},
                    {id: 15,name: 'DGSGW1015'},
                    {id: 16,name: 'DGSGW1016'},
                    {id: 17,name: 'DGSGW1017'},
                    {id: 18,name: 'DGSGW1018'}
                ]
            }
        ]
    };
    $scope.flowtree = {
        obj: "",
        filter: "",
        data: [
            {
                id:1,
                name:"全选",
                children:[
                    {id: 1,name: '广东电信网外_电信'},
                    {id: 2,name: '广西电信网外_电信'},
                    {id: 3,name: '福建电信网外_电信'},
                    {id: 4,name: '黑龙江电信网外_电信'},
                    {id: 5,name: '中国电信网外_电信'},
                    {id: 6,name: '河南电信网外_电信'},
                    {id: 4,name: '湖北电信网外_电信'},
                    {id: 5,name: '湖南电信网外_电信'},
                    {id: 6,name: '上海电信网外_电信'}
                ]
            }
        ]
    };
    /*一级页面*/
    $scope.firstdimentree = {
        obj: "",
        filter: "",
        data: [
            {
                id:1,
                name:"维度",
                children:[
                    {id: 1,name: '业务'},
                    {id: 2,name: '网元'},
                    {id: 3,name: '流向'}
                ]
            }

        ]
    };
    $scope.firstindicatortree = {
        obj: "",
        filter: "",
        data: [
            {
                id:1,
                name:"指标",
                children:[
                    {id: 1,name: '成功率'},
                    {id: 2,name: '速率'}
                ]
            }
        ]
    };
    $scope.firstindicatorgrid = {
        gridpagedata:{
            nowpage:1,
            totalpage:20,
            totalcount:20,
            startline:1,
            endline:20,
            pagesize:20,
            pagelist:[10,20,50,100],
            datacount:20,
            toFirstpage: function(){
                //alert('首页');
                $scope.indicatorgrid.gridpagedata.nowpage = 1;
                var condition ={
                    pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                    pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                    starttime:$("#starttime").val(),
                    endtime:$("#endtime").val(),
                    timesize:$scope.timesize,
                    dimension:$scope.dimension
                }
                $scope.indicatorGridturnPage(condition);
            },
            toToppage: function(){
                //alert('上一页');
                if ($scope.indicatorgrid.gridpagedata.nowpage > 1) {
                    $scope.indicatorgrid.gridpagedata.nowpage--;
                    var condition ={
                        pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                        pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                        starttime:$("#starttime").val(),
                        endtime:$("#endtime").val(),
                        timesize:$scope.timesize,
                        dimension:$scope.dimension
                    }
                    $scope.indicatorGridturnPage(condition);
                }
            },
            toNextpage: function(){
                //alert('下一页');
                if ($scope.indicatorgrid.gridpagedata.nowpage < $scope.indicatorgrid.gridpagedata.totalpage) {
                    $scope.indicatorgrid.gridpagedata.nowpage++;
                    var condition ={
                        pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                        pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                        starttime:$("#starttime").val(),
                        endtime:$("#endtime").val(),
                        timesize:$scope.timesize,
                        dimension:$scope.dimension
                    }
                    $scope.indicatorGridturnPage(condition);
                }
            },
            toLastpage: function(){
                //alert('最后一页');
                $scope.indicatorgrid.gridpagedata.nowpage = $scope.indicatorgrid.gridpagedata.totalpage;
                var condition ={
                    pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                    pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                    starttime:$("#starttime").val(),
                    endtime:$("#endtime").val(),
                    timesize:$scope.timesize,
                    dimension:$scope.dimension
                }
                $scope.indicatorGridturnPage(condition);
            },
            topage: function(){
                //alert('第' + $scope.grid1.gridpagedata.nowpage + '页');
                var condition ={
                    pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                    pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                    starttime:$("#starttime").val(),
                    endtime:$("#endtime").val(),
                    timesize:$scope.timesize,
                    dimension:$scope.dimension
                }
                $scope.indicatorGridturnPage(condition);
            },
            changePagesize: function(){
                //alert('切换到每页' + $scope.grid1.gridpagedata.pagesize + '条');
                $scope.indicatorgrid.gridpagedata.nowpage = 1;
                var condition ={
                    pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                    pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                    starttime:$("#starttime").val(),
                    endtime:$("#endtime").val(),
                    timesize:$scope.timesize,
                    dimension:$scope.dimension
                }
                $scope.indicatorGridturnPage(condition);
            }
        },
        griddata: {
            colnames: [ "比较日期",'查询日期','业务','网元','流向','权重波动','调度量','a值贡献度','速率','速率变化值','速率变化率'],
            colmodel: [
                { name: 'CompareTime', index: 'CompareTime', sortable: true, align:"center"},
                { name: 'QueryTime', index: 'QueryTime', sortable: true,align:"center" },
                { name: 'Service', index: 'Service', sortable: true, align:"center"},
                { name: 'NetUint', index: 'NetUint', sortable: true, align:"center"},
                { name: 'Flow', index: 'Flow', sortable: true, align:"center"},
                { name: 'WeightWave', index: 'WeightWave', sortable: true, align:"center"},
                { name: 'DispatchValue', index: 'DispatchValue', sortable: true, align:"center"},
                { name: 'aValue', index: 'aValue', sortable: true, align:"center"},
                { name: 'Rate', index: 'Rate', sortable: true, align:"center"},
                { name: 'RateChangeValue', index: 'RateChangeValue', sortable: true, align:"center"},
                { name: 'RateChangePercent', index: 'RateChangePercent', sortable: true, align:"center"}
            ],
            data: [
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"总计","WeightWave":"0.00%","DispatchValue":"3.51%","Rate":"3031","RateChangeValue":"52","RateChangePercent":"1.72%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"视频","NetUint":"DOGSAEGW101BHw","WeightWave":"3.36%","aValue":"1.86%","Rate":"3227","RateChangeValue":"90","RateChangePercent":"2.80%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"浏览下载","NetUint":"DOGSAEGW101BHw","WeightWave":"-1.27%","aValue":"-0.31%","Rate":"3033","RateChangeValue":"-73","RateChangePercent":"-2.40%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"NULL","NetUint":"DOGSAEGW101BHw","WeightWave":"-0.27%","aValue":"0.33%","Rate":"1524","RateChangeValue":"59","RateChangePercent":"3.84%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"应用商店","NetUint":"DOGSAEGW101BHw","WeightWave":"-0.71%","aValue":"-0.26%","Rate":"6516","RateChangeValue":"-267","RateChangePercent":"-4.09%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"即时通信","NetUint":"DOGSAEGW101BHw","WeightWave":"-0.88%","aValue":"0.14%","Rate":"3849","RateChangeValue":"234","RateChangePercent":"6.07%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"音乐","NetUint":"DOGSAEGW101BHw","WeightWave":"-0.02%","aValue":"0.02%","Rate":"3444","RateChangeValue":"-6","RateChangePercent":"-0.17%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"其他","NetUint":"DOGSAEGW101BHw","WeightWave":"0.11%","aValue":"0.04%","Rate":"2828","RateChangeValue":"61","RateChangePercent":"2.16%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"P2P业务","NetUint":"DOGSAEGW101BHw","WeightWave":"0.05%","aValue":"0.05%","Rate":"7601","RateChangeValue":"-686","RateChangePercent":"-9.02%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"微博社区","NetUint":"DOGSAEGW101BHw","WeightWave":"-0.05%","aValue":"-0.17%","Rate":"1593","RateChangeValue":"-64","RateChangePercent":"-4.05%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"游戏","NetUint":"DOGSAEGW101BHw","WeightWave":"-0.15%","aValue":"-0.03%","Rate":"4066","RateChangeValue":"-60","RateChangePercent":"-1.46%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"购物","NetUint":"DOGSAEGW101BHw","WeightWave":"-0.06%","aValue":"-0.06%","Rate":"5306","RateChangeValue":"-929","RateChangePercent":"-17.50%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"支付","NetUint":"DOGSAEGW101BHw","WeightWave":"-0.02%","aValue":"0.01%","Rate":"5618","RateChangeValue":"394","RateChangePercent":"7.01%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"网盘云服务","NetUint":"DOGSAEGW101BHw","WeightWave":"-0.01%","aValue":"0.01%","Rate":"3868","RateChangeValue":"154","RateChangePercent":"3.98%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"阅读","NetUint":"DOGSAEGW101BHw","WeightWave":"-0.02%","aValue":"0.03%","Rate":"995","RateChangeValue":"-18","RateChangePercent":"-1.77%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"导航","NetUint":"DOGSAEGW101BHw","WeightWave":"-0.01%","aValue":"0.02%","Rate":"5585","RateChangeValue":"1810","RateChangePercent":"32.41%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"安全杀毒","NetUint":"DOGSAEGW101BHw","WeightWave":"-0.02%","aValue":"0.00%","Rate":"1938","RateChangeValue":"-198","RateChangePercent":"-10.21%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"VoIP业务","NetUint":"DOGSAEGW101BHw","WeightWave":"-0.02%","aValue":"0.06%","Rate":"973","RateChangeValue":"141","RateChangePercent":"14.47%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"财经","NetUint":"DOGSAEGW101BHw","WeightWave":"-0.02%","aValue":"0.00%","Rate":"4990","RateChangeValue":"76","RateChangePercent":"1.53%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"动漫","NetUint":"DOGSAEGW101BHw","WeightWave":"0.00%","aValue":"0.00%","Rate":"7058","RateChangeValue":"840","RateChangePercent":"11.90%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"邮箱","NetUint":"DOGSAEGW101BHw","WeightWave":"0.00%","aValue":"0.00%","Rate":"5115","RateChangeValue":"619","RateChangePercent":"12.11%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"出行旅游","NetUint":"DOGSAEGW101BHw","WeightWave":"0.00%","aValue":"0.00%","Rate":"7284","RateChangeValue":"1813","RateChangePercent":"24.89%"},
                {"CompareTime":"2017/4/8","QueryTime":"2017/4/9","Service":"彩信","NetUint":"DOGSAEGW101BHw","WeightWave":"0.00%","aValue":"0.00%","Rate":"13759",},

            ]
        },
        obj:{},
        caption:'整体指标',
        shrinkToFit:true,
        gridresize: function (grid) {
            grid.setGridWidth(parseInt($(window).width()-58));
            grid.setGridHeight(parseInt(($(window).height()-257)));
        }
    };
    /*二级页面*/
    $scope.seconddimentree1 = {
        obj: "",
        filter: "",
        data: [
            {
                id:1,
                name:"维度",
                children:[
                    {id: 1,name: '业务'},
                    {id: 2,name: '网元'},
                    {id: 3,name: '流向'}
                ]
            }

        ]
    };
    $scope.seconddimentree2 = {
        obj: "",
        filter: "",
        data: [
            {
                id:1,
                name:"视频",
                children:[
                    {id: 1,name: '腾讯视频'},
                    {id: 2,name: '爱奇艺'},
                    {id: 3,name: '百度视频'}
                ]
            }

        ]
    };
    $scope.secondindicatortree = {
        obj: "",
        filter: "",
        data: [
            {
                id:1,
                name:"指标",
                children:[
                    {id: 1,name: '成功率'},
                    {id: 2,name: '速率'}
                ]
            }
        ]
    };
    $scope.secondindicatorgrid = {
        gridpagedata:{
            nowpage:1,
            totalpage:20,
            totalcount:20,
            startline:1,
            endline:20,
            pagesize:20,
            pagelist:[10,20,50,100],
            datacount:20,
            toFirstpage: function(){
                //alert('首页');
                $scope.indicatorgrid.gridpagedata.nowpage = 1;
                var condition ={
                    pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                    pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                    starttime:$("#starttime").val(),
                    endtime:$("#endtime").val(),
                    timesize:$scope.timesize,
                    dimension:$scope.dimension
                }
                $scope.indicatorGridturnPage(condition);
            },
            toToppage: function(){
                //alert('上一页');
                if ($scope.indicatorgrid.gridpagedata.nowpage > 1) {
                    $scope.indicatorgrid.gridpagedata.nowpage--;
                    var condition ={
                        pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                        pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                        starttime:$("#starttime").val(),
                        endtime:$("#endtime").val(),
                        timesize:$scope.timesize,
                        dimension:$scope.dimension
                    }
                    $scope.indicatorGridturnPage(condition);
                }
            },
            toNextpage: function(){
                //alert('下一页');
                if ($scope.indicatorgrid.gridpagedata.nowpage < $scope.indicatorgrid.gridpagedata.totalpage) {
                    $scope.indicatorgrid.gridpagedata.nowpage++;
                    var condition ={
                        pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                        pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                        starttime:$("#starttime").val(),
                        endtime:$("#endtime").val(),
                        timesize:$scope.timesize,
                        dimension:$scope.dimension
                    }
                    $scope.indicatorGridturnPage(condition);
                }
            },
            toLastpage: function(){
                //alert('最后一页');
                $scope.indicatorgrid.gridpagedata.nowpage = $scope.indicatorgrid.gridpagedata.totalpage;
                var condition ={
                    pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                    pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                    starttime:$("#starttime").val(),
                    endtime:$("#endtime").val(),
                    timesize:$scope.timesize,
                    dimension:$scope.dimension
                }
                $scope.indicatorGridturnPage(condition);
            },
            topage: function(){
                //alert('第' + $scope.grid1.gridpagedata.nowpage + '页');
                var condition ={
                    pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                    pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                    starttime:$("#starttime").val(),
                    endtime:$("#endtime").val(),
                    timesize:$scope.timesize,
                    dimension:$scope.dimension
                }
                $scope.indicatorGridturnPage(condition);
            },
            changePagesize: function(){
                //alert('切换到每页' + $scope.grid1.gridpagedata.pagesize + '条');
                $scope.indicatorgrid.gridpagedata.nowpage = 1;
                var condition ={
                    pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                    pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                    starttime:$("#starttime").val(),
                    endtime:$("#endtime").val(),
                    timesize:$scope.timesize,
                    dimension:$scope.dimension
                }
                $scope.indicatorGridturnPage(condition);
            }
        },
        griddata: {
            colnames: [ "比较日期",'查询日期','业务','流向','权重波动','调度量','a值贡献度','速率','速率变化值','速率变化率'],
            colmodel: [
                { name: 'comparetime', index: 'comparetime', sortable: true, align:"center"},
                { name: 'querytime', index: 'querytime', sortable: true,align:"center" },
                { name: 'service', index: 'service', sortable: true, align:"center"},
                { name: 'flow', index: 'flow', sortable: true, align:"center"},
                { name: 'weightwave', index: 'weightwave', sortable: true, align:"center"},
                { name: 'dispatchvalue', index: 'dispatchvalue', sortable: true, align:"center"},
                { name: 'avalue', index: 'avalue', sortable: true, align:"center"},
                { name: 'rate', index: 'rate', sortable: true, align:"center"},
                { name: 'ratechangevalue', index: 'ratechangevalue', sortable: true, align:"center"},
                { name: 'ratechangepercent', index: 'ratechangepercent', sortable: true, align:"center"}
            ],
            data: [
                { "comparetime": "2017-04-04", "querytime": "2017-04-05", "service":"视频", "flow": "外网-联通","weightwave": "96.98","dispatchvalue":"98.99"},
                { "comparetime": "2017-04-04", "querytime": "2017-04-05", "service":"浏览", "flow": "外网-联通","weightwave": "96.98","dispatchvalue":"98.99"}
            ]
        },
        obj:{},
        shrinkToFit:true,
        caption:'二级页面',
        gridresize: function (grid) {
            grid.setGridWidth(parseInt($(window).width()-58));
            grid.setGridHeight(parseInt(($(window).height()-257)));
        }
    };
    /*三级页面*/
    $scope.thirddimentree1 = {
        obj: "",
        filter: "",
        data: [
            {
                id:1,
                name:"维度",
                children:[
                    {id: 1,name: '业务'},
                    {id: 2,name: '网元'},
                    {id: 3,name: '流向'}
                ]
            }

        ]
    };
    $scope.thirddimentree2 = {
        obj: "",
        filter: "",
        data: [
            {
                id:1,
                name:"视频",
                children:[
                    {id: 1,name: '腾讯视频'},
                    {id: 2,name: '爱奇艺'},
                    {id: 3,name: '百度视频'}
                ]
            }

        ]
    };
    $scope.thirddimentree3 = {
        obj: "",
        filter: "",
        data: [
            {
                id:1,
                name:"腾讯视频",
                children:[
                    {id: 1,name: '10.203.90.78'},
                    {id: 2,name: 'www.ddck.com'},
                    {id: 3,name: 'www.jjij.com'}
                ]
            }

        ]
    };
    $scope.thirdindicatortree = {
        obj: "",
        filter: "",
        data: [
            {
                id:1,
                name:"指标",
                children:[
                    {id: 1,name: '成功率'},
                    {id: 2,name: '速率'}
                ]
            }
        ]
    };
    $scope.thirdindicatorgrid = {
        gridpagedata:{
            nowpage:1,
            totalpage:20,
            totalcount:20,
            startline:1,
            endline:20,
            pagesize:20,
            pagelist:[10,20,50,100],
            datacount:20,
            toFirstpage: function(){
                //alert('首页');
                $scope.indicatorgrid.gridpagedata.nowpage = 1;
                var condition ={
                    pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                    pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                    starttime:$("#starttime").val(),
                    endtime:$("#endtime").val(),
                    timesize:$scope.timesize,
                    dimension:$scope.dimension
                }
                $scope.indicatorGridturnPage(condition);
            },
            toToppage: function(){
                //alert('上一页');
                if ($scope.indicatorgrid.gridpagedata.nowpage > 1) {
                    $scope.indicatorgrid.gridpagedata.nowpage--;
                    var condition ={
                        pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                        pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                        starttime:$("#starttime").val(),
                        endtime:$("#endtime").val(),
                        timesize:$scope.timesize,
                        dimension:$scope.dimension
                    }
                    $scope.indicatorGridturnPage(condition);
                }
            },
            toNextpage: function(){
                //alert('下一页');
                if ($scope.indicatorgrid.gridpagedata.nowpage < $scope.indicatorgrid.gridpagedata.totalpage) {
                    $scope.indicatorgrid.gridpagedata.nowpage++;
                    var condition ={
                        pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                        pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                        starttime:$("#starttime").val(),
                        endtime:$("#endtime").val(),
                        timesize:$scope.timesize,
                        dimension:$scope.dimension
                    }
                    $scope.indicatorGridturnPage(condition);
                }
            },
            toLastpage: function(){
                //alert('最后一页');
                $scope.indicatorgrid.gridpagedata.nowpage = $scope.indicatorgrid.gridpagedata.totalpage;
                var condition ={
                    pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                    pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                    starttime:$("#starttime").val(),
                    endtime:$("#endtime").val(),
                    timesize:$scope.timesize,
                    dimension:$scope.dimension
                }
                $scope.indicatorGridturnPage(condition);
            },
            topage: function(){
                //alert('第' + $scope.grid1.gridpagedata.nowpage + '页');
                var condition ={
                    pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                    pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                    starttime:$("#starttime").val(),
                    endtime:$("#endtime").val(),
                    timesize:$scope.timesize,
                    dimension:$scope.dimension
                }
                $scope.indicatorGridturnPage(condition);
            },
            changePagesize: function(){
                //alert('切换到每页' + $scope.grid1.gridpagedata.pagesize + '条');
                $scope.indicatorgrid.gridpagedata.nowpage = 1;
                var condition ={
                    pageindex:$scope.indicatorgrid.gridpagedata.nowpage,
                    pagesize:$scope.indicatorgrid.gridpagedata.pagesize,
                    starttime:$("#starttime").val(),
                    endtime:$("#endtime").val(),
                    timesize:$scope.timesize,
                    dimension:$scope.dimension
                }
                $scope.indicatorGridturnPage(condition);
            }
        },
        griddata: {
            colnames: [ "比较日期",'查询日期','业务','流向','权重波动','调度量','a值贡献度','速率','速率变化值','速率变化率'],
            colmodel: [
                { name: 'comparetime', index: 'comparetime', sortable: true, align:"center"},
                { name: 'querytime', index: 'querytime', sortable: true,align:"center" },
                { name: 'service', index: 'service', sortable: true, align:"center"},
                { name: 'flow', index: 'flow', sortable: true, align:"center"},
                { name: 'weightwave', index: 'weightwave', sortable: true, align:"center"},
                { name: 'dispatchvalue', index: 'dispatchvalue', sortable: true, align:"center"},
                { name: 'avalue', index: 'avalue', sortable: true, align:"center"},
                { name: 'rate', index: 'rate', sortable: true, align:"center"},
                { name: 'ratechangevalue', index: 'ratechangevalue', sortable: true, align:"center"},
                { name: 'ratechangepercent', index: 'ratechangepercent', sortable: true, align:"center"}
            ],
            data: [
                { "comparetime": "2017-04-04", "querytime": "2017-04-05", "service":"视频", "flow": "外网-联通","weightwave": "96.98","dispatchvalue":"98.99"},
                { "comparetime": "2017-04-04", "querytime": "2017-04-05", "service":"浏览", "flow": "外网-联通","weightwave": "96.98","dispatchvalue":"98.99"}
            ]
        },
        obj:{},
        shrinkToFit:true,
        caption:'三级页面',
        gridresize: function (grid) {
            grid.setGridWidth(parseInt($(window).width()-58));
            grid.setGridHeight(parseInt(($(window).height()-257)));
        }
    };

    $scope.init = function () {
        setTimeout(function(){
            $scope.$apply($scope.expand = function(){
                var treeObj = $.fn.zTree.getZTreeObj("servicetree");
                treeObj.expandAll(true);

                treeObj = $.fn.zTree.getZTreeObj("netunittree");
                treeObj.expandAll(true);

                treeObj = $.fn.zTree.getZTreeObj("flowtree");
                treeObj.expandAll(true);
            });
        }, 1000);
    }
    $scope.init();
}
ResourceDispatchController.$inject = ['$scope', '$filter', 'Excel', '$timeout', '$stateParams', 'HttpRequestService', 'CheckDateUtils'];
